package cn.gameo2o.controller.lcgl;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.gameo2o.pojo.O2o_play;
import cn.gameo2o.pojo.O2o_playflow;
import cn.gameo2o.service.lcgl.LiuChengGuanLiService;
import cn.gameo2o.util.PageParam;
@RestController
@RequestMapping("/lcgl")
public class LiuChengGuanLiController {
	 @Resource()
	    private LiuChengGuanLiService lcglService;

	    public LiuChengGuanLiService getStudentService() {
	        return lcglService;
	    }

	    public void setStudentService(LiuChengGuanLiService  LiuChenService) {
	        this.lcglService =  LiuChenService;
	    }
	    @RequestMapping("/find")
	    public PageParam findAll(@RequestParam(required = false) String playname,@RequestParam(required = false) Date opentime,@RequestParam(required=false) Date closetime,@RequestParam(required=false) String states,@RequestParam() Integer limit,@RequestParam() Integer offset){
	          Map param=new HashMap();
	          if(playname!=null) {
	              param.put("username", playname);
	          }
	          if(opentime!=null){
	              param.put("opentime",opentime);
	          }
	          if(closetime!=null)
	          {
	              param.put("closetime",closetime);  
	          }
	          if(states!=null)
	          {
	        	  param.put("states",states);   
	          }
	          PageParam page=new PageParam();
	          page.setPageSize(limit);
	          page.setFirst(offset);
	          lcglService.find(param,page);
	          return page;
	    }
	    @RequestMapping("/save")
	    public String save(@ModelAttribute O2o_play user){
	    lcglService.save(user);
	    return "添加成功！";
	    
	    }
	    @RequestMapping("/Delete")
	    public String delete(@RequestParam(value = "sid",required = false) String id){
	    	lcglService.Delete(Integer.parseInt(id));
	        return "删除成功！";
	    }
	    @RequestMapping("/findById")
	    public O2o_playflow  findById(@RequestParam(value="sid",required=false) String id ){
	    	O2o_playflow   users = lcglService.findById(Integer.parseInt(id));
	        return users;
	    }

	    @RequestMapping("/update")
	    public String update(@ModelAttribute O2o_play play){
	    	lcglService.update(play);
	        return "更新成功！";
	    }
	}

